package com.bookstore.service;

import java.util.List;

import com.bookstore.dao.DAOFactory;
import com.bookstore.dao.UserDAO;
import com.bookstore.model.User;

public class UserServiceImpl implements UserService {

	@Override
	public List<User> findAll() throws Exception {
		UserDAO userDAO = DAOFactory.getUserDAO();
		List<User> list = userDAO.findAll();
		return list;
	}

	@Override
	public void save(User user) throws Exception {
		UserDAO userDAO = DAOFactory.getUserDAO();
		userDAO.save(user);
	}

	@Override
	public User findByEmail(String email) throws Exception {
		UserDAO userDAO = DAOFactory.getUserDAO();
		return userDAO.findByEmail(email);
	}

	@Override
	public User findById(int id) throws Exception {
		UserDAO userDAO = DAOFactory.getUserDAO();
		return userDAO.findById(id);
	}

	@Override
	public void update(User user) throws Exception {
		UserDAO userDAO = DAOFactory.getUserDAO();
		userDAO.update(user);
	}

}
